package com.trace.meat.controller;

import com.trace.meat.entity.Stock;
import com.trace.meat.entity.TestOnly;
import com.trace.meat.service.TestOnlyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TestOnly)表控制层
 *
 * @author makejava
 * @since 2021-06-19 11:17:31
 */
@RestController
@RequestMapping("testOnly")
public class TestOnlyController {
    /**
     * 服务对象
     */
    @Resource
    private TestOnlyService testOnlyService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TestOnly selectOne(Integer id) {
        return this.testOnlyService.queryById(id);
    }
    /**
     * 新增数据
     */
    //http://127.0.0.1:11451/testOnly/insertOne?str=jkl&state=2&jtest=yui
    @GetMapping("insertOne")
    public TestOnly insert(String str, Short state, String jtest) {
        TestOnly testOnly=new TestOnly();
        testOnly.setStr(str);
        testOnly.setState(state);
        testOnly.setJtest(jtest);
        return this.testOnlyService.insert(testOnly);
    }
    /**
     * 更新数据
     *
     */
    //http://127.0.0.1:11451/testOnly/updateOne?id=5&str=hjk
    @GetMapping("updateOne")
    public TestOnly update(Integer id, String str, Short state, String jtest) {
        TestOnly testOnly=new TestOnly();
        testOnly.setId(id);
        testOnly.setStr(str);
        testOnly.setState(state);
        testOnly.setJtest(jtest);
        return testOnlyService.update(testOnly);
    }
    /**
     * 删除数据
     */
    //http://127.0.0.1:11451/testOnly/deleteOne?id=2
    @GetMapping("deleteOne")
    public boolean deleteById(Integer id) {
        return testOnlyService.deleteById(id);
    }
}
